//
//  FactorySectionView.m
//  Rail
//
//  Created by hychen on 2018/3/5.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "FactorySectionView.h"

@interface FactorySectionView ()

@property (nonatomic, weak) UITapGestureRecognizer *tap;
@end
@implementation FactorySectionView

+ (instancetype)sectionView {
    FactorySectionView *factory = [[[NSBundle mainBundle] loadNibNamed:@"FactorySectionView" owner:self options:nil] lastObject];
    return factory;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    BMLineView *lineView = [BMLineView lineViewWithFrame:CGRectZero];
    [self addSubview:lineView];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self);
        make.height.mas_equalTo(0.5);
    }];
}

- (void)setCanClick:(BOOL)canClick {
    _canClick = canClick;
    if (!self.tap) {
        self.userInteractionEnabled = YES;
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickSection)];
        self.tap = tapGesture;
        [self addGestureRecognizer:tapGesture];
    }
}

- (void)clickSection {
    if (self.BlockClick) {
        self.BlockClick(self.section);
    }
}

@end
